const upload = async function(vm, {
	// #ifdef APP-PLUS || H5
	files,
	// #endif
	// #ifdef H5
	file,
	// #endif
	// #ifdef MP-ALIPAY
	fileType,
	// #endif
	filePath,
	name,
	formData
}) {
	return new Promise((resolve, reject) => {
		uni.showLoading({
			mask: true,
			title: '上传中'
		});
		let data = {
			url: vm.vuex_config.upload.uploadurl,
			header: {
				token: vm.vuex_token || '',
				uid: vm.vuex_user.id || 0
			},
			name: 'file',
			complete: function() {
				uni.hideLoading();
			},
			success: uploadFileRes => {
				try {
					var res = uploadFileRes.data;
					if (vm.$u.test.jsonString(res)) {
						resolve(JSON.parse(res))
					}
					if (vm.$u.test.object(res)) {
						resolve(res)
					}
				} catch (e) {
					reject(uploadFileRes.data);
				}
			},
			fail: (e) => {
				reject(e);
			}
		};
		// #ifdef H5
		//有文件对象，一般是H5
		if (file) {
			data.file = file;
		}
		// #endif
		//文件路径
		if (filePath) {
			data.filePath = filePath;
		}
		let isObj = vm.$u.test.object(vm.vuex_config.upload.multipart);
		if (isObj && formData) {
			data.formData = Object.assign(formData, vm.vuex_config.upload.multipart);
		} else if (isObj) {
			data.formData = vm.vuex_config.upload.multipart;
		} else if (formData) {
			data.formData = formData;
		}
		uni.uploadFile(data);
	})

}


const install = (Vue, vm) => {

	vm.$api.getConfig = async (params = {}) => await vm.$u.get('/addons/ask/api.common/config', params);
	vm.$api.getEmsSend = async (params = {}) => await vm.$u.post('/addons/ask/api.ems/send', params);
	vm.$api.getSmsSend = async (params = {}) => await vm.$u.post('/addons/ask/api.sms/send', params);
	vm.$api.getSearchIndex = async (params = {}) => await vm.$u.get('/addons/ask/api.search/index', params); //普通搜索
	vm.$api.getMyboutus = async (params = {}) => await vm.$u.get('/addons/ask/api.common/aboutus', params);
	vm.$api.getMyagree = async (params = {}) => await vm.$u.get('/addons/ask/api.common/agreement', params);
	vm.$api.getQuestionIndex = async (params = {}) => await vm.$u.get('/addons/ask/api.question/index', params);
	vm.$api.getQuestionShow = async (params = {}) => await vm.$u.get('/addons/ask/api.question/show', params);
	vm.$api.getQuestionClose = async (params = {}) => await vm.$u.post('/addons/ask/api.question/close', params);
	vm.$api.getQuestionOpen = async (params = {}) => await vm.$u.post('/addons/ask/api.question/open', params);
	vm.$api.getQuestionDelete = async (params = {}) => await vm.$u.post('/addons/ask/api.question/delete', params);
	vm.$api.getQuestionConfig = async (params = {}) => await vm.$u.get('/addons/ask/api.question/config', params);
	vm.$api.goQuestionConfig = async (params = {}) => await vm.$u.post('/addons/ask/api.question/config', params);
	vm.$api.getQuestionReward = async (params = {}) => await vm.$u.post('/addons/ask/api.question/reward', params);
	vm.$api.getQuestionAdopt = async (params = {}) => await vm.$u.post('/addons/ask/api.question/adopt', params);
	vm.$api.getQuestionPost = async (params = {}) => await vm.$u.get('/addons/ask/api.question/post', params);
	vm.$api.goQuestionPost = async (params = {}) => await vm.$u.post('/addons/ask/api.question/post', params);
	vm.$api.getQuestionUpdate = async (params = {}) => await vm.$u.get('/addons/ask/api.question/update', params);
	vm.$api.goQuestionUpdate = async (params = {}) => await vm.$u.post('/addons/ask/api.question/update', params);
	vm.$api.goAnswerPost = async (params = {}) => await vm.$u.post('/addons/ask/api.answer/post', params);
	vm.$api.goAnswerDelete = async (params = {}) => await vm.$u.post('/addons/ask/api.answer/delete', params);
	vm.$api.getAnswerUpdate = async (params = {}) => await vm.$u.get('/addons/ask/api.answer/update', params);
	vm.$api.goAnswerUpdate = async (params = {}) => await vm.$u.post('/addons/ask/api.answer/update', params);
	vm.$api.getAnswerList = async (params = {}) => await vm.$u.get('/addons/ask/api.ajax/get_answer_list', params);
	vm.$api.getCommentList = async (params = {}) => await vm.$u.get('/addons/ask/api.ajax/get_comment_list',
	params);
	vm.$api.getQuestionList = async (params = {}) => await vm.$u.get('/addons/ask/api.ajax/get_question_list',
		params);
	vm.$api.getArticleList = async (params = {}) => await vm.$u.get('/addons/ask/api.ajax/get_article_list',
	params);
	vm.$api.getArticleIndex = async (params = {}) => await vm.$u.get('/addons/ask/api.article/index', params);
	vm.$api.getArticleShow = async (params = {}) => await vm.$u.get('/addons/ask/api.article/show', params);
	vm.$api.getArticleDelete = async (params = {}) => await vm.$u.post('/addons/ask/api.article/delete', params);
	vm.$api.getArticleConfig = async (params = {}) => await vm.$u.get('/addons/ask/api.article/config', params);
	vm.$api.goArticleConfig = async (params = {}) => await vm.$u.post('/addons/ask/api.article/config', params);
	vm.$api.getArticlePost = async (params = {}) => await vm.$u.get('/addons/ask/api.article/post', params);
	vm.$api.goArticlePost = async (params = {}) => await vm.$u.post('/addons/ask/api.article/post', params);
	vm.$api.getArticleUpdate = async (params = {}) => await vm.$u.get('/addons/ask/api.article/update', params);
	vm.$api.goArticleUpdate = async (params = {}) => await vm.$u.post('/addons/ask/api.article/update', params);
	vm.$api.getZoneIndex = async (params = {}) => await vm.$u.get('/addons/ask/api.zone/index', params);
	vm.$api.getZoneShow = async (params = {}) => await vm.$u.get('/addons/ask/api.zone/show', params);
	vm.$api.getTagShow = async (params = {}) => await vm.$u.get('/addons/ask/api.tag/show', params);
	vm.$api.getExpertIndex = async (params = {}) => await vm.$u.get('/addons/ask/api.expert/index', params);
	vm.$api.getExpertCreate = async (params = {}) => await vm.$u.post('/addons/ask/api.expert/create', params);
	vm.$api.getExpertGet = async (params = {}) => await vm.$u.post('/addons/ask/api.expert/info', params);
	vm.$api.getLogin = async (params = {}) => await vm.$u.post('/addons/ask/api.login/login', params);
	vm.$api.mobilelogin = async (params = {}) => await vm.$u.post('/addons/ask/api.login/mobilelogin', params);
	vm.$api.getRegister = async (params = {}) => await vm.$u.post('/addons/ask/api.login/register', params);
	vm.$api.getResetpwd = async (params = {}) => await vm.$u.post('/addons/ask/api.login/resetpwd', params);
	vm.$api.gowxLogin = async (params = {}) => await vm.$u.post('/addons/ask/api.login/wxLogin', params);
	vm.$api.goAppLogin = async (params = {}) => await vm.$u.post('/addons/ask/api.login/appLogin', params);
	vm.$api.getWechatMobile = async (params = {}) => await vm.$u.post('/addons/ask/api.login/getWechatMobile',
		params);
	vm.$api.getMyinfo = async (params = {}) => await vm.$u.get('/addons/ask/api.user/myinfo', params);
	vm.$api.getUserIndex = async (params = {}) => await vm.$u.get('/addons/ask/api.user/index', params);
	vm.$api.getUserQuestion = async (params = {}) => await vm.$u.get('/addons/ask/api.user/question', params);
	vm.$api.getUserAnswer = async (params = {}) => await vm.$u.get('/addons/ask/api.user/answer', params);
	vm.$api.getUserArticle = async (params = {}) => await vm.$u.get('/addons/ask/api.user/article', params);
	vm.$api.getUserFollower = async (params = {}) => await vm.$u.get('/addons/ask/api.user/follower', params);
	vm.$api.getUserAttention = async (params = {}) => await vm.$u.get('/addons/ask/api.user/attention', params);
	vm.$api.getUserCollection = async (params = {}) => await vm.$u.get('/addons/ask/api.user/collection', params);
	vm.$api.getUserNotification = async (params = {}) => await vm.$u.get('/addons/ask/api.user/notification',
		params);
	vm.$api.getUserMessage = async (params = {}) => await vm.$u.get('/addons/ask/api.user/message', params);
	vm.$api.getUserInvite = async (params = {}) => await vm.$u.get('/addons/ask/api.user/invite', params);
	vm.$api.getUserProfile = async (params = {}) => await vm.$u.post('/addons/ask/api.user/profile', params);
	vm.$api.getUserResetpwd = async (params = {}) => await vm.$u.post('/addons/ask/api.user/resetpwd', params);
	vm.$api.getUserLogout = async (params = {}) => await vm.$u.get('/addons/ask/api.user/logout', params);
	vm.$api.getMyTotal = async (params = {}) => await vm.$u.get('/addons/ask/api.user/myTotal', params);
	vm.$api.getSigned = async (params = {}) => await vm.$u.post('/addons/ask/api.user/getSigned', params);
	vm.$api.goCommentPost = async (params = {}) => await vm.$u.post('/addons/ask/api.comment/post', params);
	vm.$api.goCommentUpdate = async (params = {}) => await vm.$u.post('/addons/ask/api.comment/update', params);
	vm.$api.goCommentDelete = async (params = {}) => await vm.$u.post('/addons/ask/api.comment/delete', params);
	vm.$api.goVoteCreate = async (params = {}) => await vm.$u.post('/addons/ask/api.vote/create', params);
	vm.$api.goVoteDelete = async (params = {}) => await vm.$u.post('/addons/ask/api.vote/delete', params);
	vm.$api.goAttentionCreate = async (params = {}) => await vm.$u.post('/addons/ask/api.attention/create', params);
	vm.$api.goAttentionDelete = async (params = {}) => await vm.$u.post('/addons/ask/api.attention/delete', params);
	vm.$api.goReportCreate = async (params = {}) => await vm.$u.post('/addons/ask/api.report/create', params);
	vm.$api.goCollectionCreate = async (params = {}) => await vm.$u.post('/addons/ask/api.collection/create',
		params);
	vm.$api.goCollectionDelete = async (params = {}) => await vm.$u.post('/addons/ask/api.collection/delete',
		params);
	vm.$api.goInviteSearch = async (params = {}) => await vm.$u.post('/addons/ask/api.invite/search', params);
	vm.$api.goInvitePost = async (params = {}) => await vm.$u.post('/addons/ask/api.invite/post', params);
	vm.$api.goMessagePost = async (params = {}) => await vm.$u.post('/addons/ask/api.message/post', params);
	vm.$api.goThanksCreate = async (params = {}) => await vm.$u.post('/addons/ask/api.thanks/create', params);
	vm.$api.goOrderSubmit = async (params = {}) => await vm.$u.post('/addons/ask/api.order/submit', params);
	vm.$api.getMoneyLogs = async (params = {}) => await vm.$u.get('/addons/ask/api.the_logs/money', params);
	vm.$api.getScoreLogs = async (params = {}) => await vm.$u.get('/addons/ask/api.the_logs/score', params);
	vm.$api.getRechargeConfig = async (params = {}) => await vm.$u.get('/addons/recharge/api.recharge/config',
		params);
	vm.$api.goRechargeSubmit = async (params = {}) => await vm.$u.post('/addons/recharge/api.recharge/submit',
		params);
	vm.$api.getAuthUrl = async (params = {}) => await vm.$u.get('/addons/third/api/getAuthUrl', params);
	vm.$api.goAuthCallback = async (params = {}) => await vm.$u.post('/addons/third/api/callback', params);
	vm.$api.goThirdAccount = async (params = {}) => await vm.$u.post('/addons/third/api/account', params);
	vm.$api.signinConfig = async (params = {}) => await vm.$u.get('/addons/signin/api.index/index', params);
	vm.$api.monthSign = async (params = {}) => await vm.$u.get('/addons/signin/api.index/monthSign', params);
	vm.$api.dosign = async (params = {}) => await vm.$u.post('/addons/signin/api.index/dosign', params);
	vm.$api.fillup = async (params = {}) => await vm.$u.post('/addons/signin/api.index/fillup', params);
	vm.$api.signRank = async (params = {}) => await vm.$u.get('/addons/signin/api.index/rank', params);
	vm.$api.signLog = async (params = {}) => await vm.$u.get('/addons/signin/api.index/signLog', params);
	vm.$api.captcha = async (params = {}) => await vm.$u.get('/addons/ask/api.common/captcha', params);
	vm.$api.goUpload = async (params = {}) => await upload(vm, params);
	vm.$api.getQuestionTags = async (params = {}) => await vm.$u.get('/addons/ask/api.question/get_tags', params);
	
	
	
	// 助餐
	vm.$api.wxlogin = async (params = {}) => await vm.$u.post('/member/authorize/wxlogin', params);
	vm.$api.checkwxlogin = async (params = {}) => await vm.$u.post('/member/authorize/checkwxlogin', params);
	vm.$api.getUserInfo = async (params = {}) => await vm.$u.get('/addons/canteen/api.user/info', params);
	vm.$api.logout = async (params = {}) => await vm.$u.post('/member/authorize/logout', params);
	vm.$api.adminlogin = async (params = {}) => await vm.$u.post('/member/authorize/login', params);
	vm.$api.register = async (params = {}) => await vm.$u.post('/member/authorize/register', params);
	vm.$api.getMoneyLog = async (params = {}) => await vm.$u.post('/restaurant/user/Money/money_log', params);
	vm.$api.getMoneyDetail = async (params = {}) => await vm.$u.post('/restaurant/user/Money/detail', params);
	vm.$api.checkAge = async (params = {}) => await vm.$u.post('/member/user/checkAge', params);
	vm.$api.realnameAuth = async (params = {}) => await vm.$u.post('/member/user/realnameAuth', params);
	vm.$api.getRealnameAuth = async (params = {}) => await vm.$u.get('/member/user/realnameAuth', params);
	vm.$api.getOrderLists = async (params = {}) => await vm.$u.post('/addons/canteen/api.order/lists', params);
	vm.$api.getOrderInfo = async (params = {}) => await vm.$u.post('/addons/canteen/api.order/detail', params);
	vm.$api.updateProfile = async (params = {}) => await vm.$u.post('/member/user/profile', params);
	vm.$api.cancelOrder = async (params = {}) => await vm.$u.post('/addons/canteen/api.order/cancel', params);
	vm.$api.getStoreLists = async (params = {}) => await vm.$u.get('/addons/canteen/api.store/lists', params);
	vm.$api.getStore = async (params = {}) => await vm.$u.get('/addons/canteen/api.store/detail', params);
	vm.$api.getArticleDetail = async (params = {}) => await vm.$u.get('/index/articledetail', params);
	vm.$api.getGoodsList = async (params = {}) => await vm.$u.post('/addons/canteen/api.goods/lists', params);
	vm.$api.getGoodsCategory = async (params = {}) => await vm.$u.post('/addons/canteen/api.goods/category', params);
	vm.$api.addCarStorage = async (params = {}) => await vm.$u.post('/addons/canteen/api.cart/storage', params);
	vm.$api.getCarStorage = async (params = {}) => await vm.$u.post('/addons/canteen/api.cart/synchro', params);
	vm.$api.getAddressList = async (params = {}) => await vm.$u.get('/restaurant/Address/getLists', params);
	vm.$api.addAddress = async (params = {}) => await vm.$u.post('/restaurant/Address/address', params);
	vm.$api.getAddressDetail = async (params = {}) => await vm.$u.post('/restaurant/Address/detail', params);
	vm.$api.delAddress = async (params = {}) => await vm.$u.post('/restaurant/Address/deladdress', params);
	vm.$api.getArea = async (params = {}) => await vm.$u.get('/index/area', params);
	vm.$api.getOrderGoodsList = async (params = {}) => await vm.$u.post('/addons/canteen/api.order/getOrderGoodsList', params);
	vm.$api.addOrder = async (params = {}) => await vm.$u.post('/addons/canteen/api.order/create', params);
	vm.$api.getAdvert = async (params = {}) => await vm.$u.get('/index/advert', params);
	vm.$api.confirmOrder = async (params = {}) => await vm.$u.post('/addons/canteen/api.order/confirm', params);
	vm.$api.getPayInfo = async (params = {}) => await vm.$u.post('/api/payment/pay/info', params);
	vm.$api.payment = async (params = {}) => await vm.$u.post('/restaurant/payment/Virtually/payment', params);
	vm.$api.deladdress = async (params = {}) => await vm.$u.post('/restaurant/Address/deladdress', params);
	vm.$api.bindusername = async (params = {}) => await vm.$u.post('/member/authorize/bindusername', params);
	vm.$api.getCouponLists = async (params = {}) => await vm.$u.get('/addons/canteen/api.coupon/lists', params);
	vm.$api.getUserCouponLists = async (params = {}) => await vm.$u.post('/addons/canteen/api.coupon/userlists', params);
	vm.$api.addReceive = async (params = {}) => await vm.$u.post('/addons/canteen/api.coupon/receive', params);
	vm.$api.getUsableCoupon = async (params = {}) => await vm.$u.post('/addons/canteen/api.coupon/usable', params);
	vm.$api.iswindow = async (params = {}) => await vm.$u.get('/restaurant/coupon/iswindow', params);
	vm.$api.getIndex = async (params = {}) => await vm.$u.post('/index/index', params);
	vm.$api.getNotice = async (params = {}) => await vm.$u.get('/article/notice', params);
	vm.$api.recharge = async (params = {}) => await vm.$u.post('/restaurant/user/money/recharge', params);
	
}

export default {
	install 
}